package com.itheima.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealCheckgroupMapper {

    /**
     * 根据套餐id查询关联的检查组id
     * @param setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);

    /**
     * 根据套餐id和检查组id列表向套餐检查组中间表批量插入数据
     * @param checkgroupIds
     * @param setmealId
     */
    void addBatch(List<Integer> checkgroupIds, Integer setmealId);

    /**
     * 根据套餐id删除关联的检查组
     * @param setmealId
     */
    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{semealId}")
    void deleteBySetmealId(Integer setmealId);

    /**
     * 根据检查组id查询该检查组是否被套餐关联
     * @param id
     * @return
     */
    @Select("select count(*) from t_setmeal_checkgroup where checkgroup_id = #{checkgroupId}")
    Long findCountByCheckgroupId(Integer checkgroupId);
}
